package com.hjxr.sysadmin.zsj.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hjxr.framework.aspectj.lang.annotation.Log;
import com.hjxr.framework.aspectj.lang.enums.BusinessType;
import com.hjxr.sysadmin.zsj.domain.Callon;
import com.hjxr.sysadmin.zsj.service.ICallonService;
import com.hjxr.sysadmin.web.controller.BaseController;
import com.hjxr.framework.web.domain.AjaxResult;
import com.hjxr.sysadmin.uitl.poi.ExcelUtil;
import com.hjxr.sysadmin.web.page.TableDataInfo;

/**
 * 拜访信息Controller
 *
 * @author zc
 * @date 2021-03-22
 */
@Api("拜访信息管理")
@RestController
@RequestMapping("/callon")
public class CallonController extends BaseController
{
    @Autowired
    private ICallonService callonService;

    /**
     * 查询拜访信息列表
     */
    @ApiOperation("查询拜访信息列表")
    //@PreAuthorize("@ss.hasPermi('system:callon:list')")
    @GetMapping("/list")
    public TableDataInfo list(Callon callon)
    {
        startPage();
        List<Callon> list = callonService.selectCallonList(callon);
        return getDataTable(list);
    }

    /**
     * 导出拜访信息列表
     */
    @ApiOperation("导出拜访信息列表")
    //@PreAuthorize("@ss.hasPermi('system:callon:export')")
    @Log(title = "导出拜访信息列表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Callon callon)
    {
        List<Callon> list = callonService.selectCallonList(callon);
        ExcelUtil<Callon> util = new ExcelUtil<Callon>(Callon.class);
        return util.exportExcel(list, "callon");
    }

    /**
     * 获取拜访信息详细信息
     */
    @ApiOperation("获取拜访信息详细信息")
    //@PreAuthorize("@ss.hasPermi('system:callon:query')")
    @GetMapping(value = "/{callonId}")
    public AjaxResult getInfo(@PathVariable("callonId") Long callonId)
    {
        return AjaxResult.success(callonService.selectCallonById(callonId));
    }

    /**
     * 新增拜访信息
     */
    @ApiOperation("新增拜访信息")
    //@PreAuthorize("@ss.hasPermi('system:callon:add')")
    @Log(title = "新增拜访信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Callon callon)
    {
        return toAjax(callonService.insertCallon(callon));
    }

    /**
     * 修改拜访信息
     */
    @ApiOperation("修改拜访信息")
    //@PreAuthorize("@ss.hasPermi('system:callon:edit')")
    @Log(title = "修改拜访信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Callon callon)
    {
        return toAjax(callonService.updateCallon(callon));
    }

    /**
     * 删除拜访信息
     */
    @ApiOperation("删除拜访信息")
    //@PreAuthorize("@ss.hasPermi('system:callon:remove')")
    @Log(title = "删除拜访信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{callonIds}")
    public AjaxResult remove(@PathVariable Long[] callonIds)
    {
        return toAjax(callonService.deleteCallonByIds(callonIds));
    }
}
